package org.icec.web.sys.service;

import org.beetl.sql.core.annotatoin.Param;
import org.icec.web.sys.dao.SysClientYxDao;
import org.icec.web.sys.model.SysClientYx;
import org.icec.web.sys.model.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

/**
 * Created by 阚文杰 on 2018/1/22/022.
 */
@Service
public class SysClientYxService {

    @Autowired
    private SysClientYxDao sysClientYxDao;
    @Autowired
    private SysFileService sysFileService;


    public SysClientYx findByClientId(@Param("id") Integer id){
        SysClientYx sysClientYx=  sysClientYxDao.findByClientId(id);
        return  sysClientYx;
    }


    /**
     * 更新操作，更新del_flag字段
     *
     * @param
     */
    @Transactional
    public void update(SysClientYx sysClientYx) {
//        sysClient.setUpdateuserid(sysUser.getId());
//        sysClient.setUpdatetime(new Date());
        sysClientYxDao.updateTemplateById(sysClientYx);
    }

    /**
     * 用户更新
     *
     * @param
     */
    @Transactional
    public void update(SysClientYx sysClientYx, SysUser optuser, Integer[] roleList, MultipartFile multiFile) {

        Long result = sysFileService.saveUploadFile("clientPhoto", multiFile, optuser);
        if(result>0) {
            sysClientYx.setPhoto(result+"");
        }
        sysClientYxDao.updateTemplateById(sysClientYx);
    }

}
